import axios from 'axios';
axios.defaults.baseURL = 'http://192.168.201.103/api/';
axios.defaults.timeout = 360000;

axios.interceptors.request.use(
  function (config) {
    return config;
  },
  function (error) {
    // 请求错误做些什么
    return Promise.reject(error);
  }
);
/**
 * 添加响应拦截器
 * */
axios.interceptors.response.use(
  function(response) {
    // 对响应数据做些什么
    return response.data;
  },
  function(error) {
    // 对响应错误做些什么
    return Promise.reject(error);
  }
);
const get = function(url, conf = {}) {
  return axios.get(url, conf).catch(function(thrown) {
      if (axios.isCancel(thrown)) {
        console.log('Request canceled');
      } else {
        // handle error
      }
    })
    .finally(() => {
    });
};

const post = (url, conf = {}) => {
  return axios.post(url, conf).catch(thrown => {
      if (axios.isCancel(thrown)) {
        console.log('Request canceled');
      } else {
        // handle error
      }
    })
    .finally(() => {
    });
};
export default {
  get,
  post
};
